package com.flower.sequence.parse;

import com.flower.sequence.segment.DateSegmentGenerator;
import com.flower.sequence.segment.FixedStringSegmentGenerator;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.w3c.dom.Element;

/**
 * @author shanks on 2019-10-12
 */

public class FixedSegmentDefinitionParse extends AbstractSingleBeanDefinitionParser {

    @Override
    protected Class<?> getBeanClass(Element element) {
        return FixedStringSegmentGenerator.class;
    }

    @Override
    protected void doParse(Element element, BeanDefinitionBuilder builder) {
        String segmentString = element.getAttribute("segmentString");
        String length = element.getAttribute("length");
        builder.addPropertyValue("segmentString", segmentString);
        builder.addPropertyValue("length", length);
    }
}
